package com.abbas.smartCity.base

import android.os.Bundle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding
import com.abbas.smartCity.util.NoImpl
import java.lang.reflect.ParameterizedType

@NoImpl
abstract class BaseBindingModelFragment<VB: ViewBinding,VM: ViewModel>:
    BaseBindingFragment<VB>() {

    protected lateinit var viewModel: VM

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        var parameterizedType = javaClass.genericSuperclass as ParameterizedType
        var clazz = parameterizedType.actualTypeArguments[1] as Class<ViewModel>
        viewModel = ViewModelProvider(this, ViewModelProvider.NewInstanceFactory()).get(clazz) as VM
    }

}